DEFINE VAR firstval AS CHARACTER.
DEFINE VAR lastval AS CHARACTER.


OUTPUT TO c:\qadguicli\dth_difvalue.xls.

FOR EACH dth_hist NO-LOCK  WHERE 
        (dth_table = "sct_det") AND 
        (dth_field = "sct_cst_tot") AND 
        (dth_Key1 = "current" ) AND 
        (dth_Program = "apvoco01.p")  
        BREAK BY dth_key2 BY dth_trnbr DESC:

    IF FIRST-OF(dth_key2) THEN DO:
    
       lastval = dth_aft_val.
    END.

    IF LAST-OF(dth_key2) THEN DO:
    
        firstval = dth_bef_val.
        IF ABS(dec(firstval) - dec(lastval)) > 0.1 THEN

           DISP  dth_Key1 dth_Key2 FORMAT "X(12)" dth_mod_date string(dth_mod_time,"HH:MM:SS") dth_trnbr
                 dth_bef_val dth_aft_val lastval WITH STREAM-IO WIDTH 200.
    END.


END.
